home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 138 / 138.xpi / chrome / stumbleupon.jar / content / widgets.xml < prev   
Extensible Markup Language  |  2009-07-02  |  27KB  |  863 lines

  1. <?xml version="1.0"?>
  2.  
  3. <!DOCTYPE window [
  4.   <!ENTITY % textcontextDTD SYSTEM "chrome://global/locale/textcontext.dtd" >
  5.   %textcontextDTD;
  6. ]>
  7.  
  8. <bindings id="su_bindings"
  9.             xmlns="http://www.mozilla.org/xbl"
  10.             xmlns:html="http://www.w3.org/1999/xhtml"
  11.             xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  12.             xmlns:xbl="http://www.mozilla.org/xbl">
  13.  
  14.             
  15.   <binding id="su_toolbarbutton" display="xul:button"
  16.            extends="chrome://global/content/bindings/button.xml#button-base">
  17.     <resources>
  18.       <stylesheet src="chrome://global/skin/toolbarbutton.css"/>
  19.     </resources>
  20.     
  21.     <content>
  22.       <children includes="observes|template|menupopup|panel|tooltip"/>
  23.       <xul:image class="toolbarbutton-icon" xbl:inherits="validate,src=image,toolbarmode,buttonstyle,label"/>
  24.       <xul:label class="toolbarbutton-text" crop="right" flex="1"
  25.                  xbl:inherits="value=label,accesskey,crop,toolbarmode,buttonstyle"/>
  26.       <xul:image class="toolbarbutton-icon" xbl:inherits="validate=validate2,src=image2,toolbarmode=toolbarmode2,buttonstyle=buttonstyle2"/>
  27.     </content>
  28.   </binding>
  29.  
  30.  
  31.   <binding id="su_menuitem-iconic" extends="chrome://global/content/bindings/menu.xml#menuitem">
  32.     <content>
  33.       <xul:hbox class="menu-iconic-left" align="center" pack="end"
  34.                 xbl:inherits="selected,_moz-menuactive,disabled,checked">
  35.         <xul:image class="menu-iconic-icon" xbl:inherits="src=image,validate,src"/>
  36.       </xul:hbox>
  37.             <xul:spacer width="5px"/>
  38.       <xul:label class="menu-iconic-text" flex="1" xbl:inherits="value=label,accesskey,crop" crop="right"/>
  39.       <xul:hbox anonid="accel">
  40.         <xul:label class="menu-iconic-accel" xbl:inherits="value=acceltext"/>
  41.       </xul:hbox>
  42.     </content>
  43.   </binding>
  44.  
  45.     <binding id="su_autocomplete"
  46.                 extends="chrome://global/content/bindings/textbox.xml#textbox">
  47.         <resources>
  48.       <stylesheet src="chrome://global/skin/autocomplete.css"/>
  49.             <stylesheet src="chrome://stumbleupon/skin/widgets.css"/>
  50.         </resources>
  51.  
  52.         <content>
  53.             <xul:hbox class="autocomplete-textbox-container" flex="1">
  54.                 <xul:hbox anonid="textbox-input-box"
  55.                             class="textbox-input-box"
  56.                             flex="1"
  57.                             xbl:inherits="tooltiptext=inputtooltiptext,contextitemalabel,contextitemaaccesskey,contextitemachecked,contextitemaoncommand,contextitemblabel,contextitembaccesskey,contextitembchecked,contextitemboncommand,contextitemclabel,contextitemcaccesskey,contextitemcchecked,contextitemconcommand">
  58.                     <html:input anonid="input"
  59.                                 class="textbox-input"
  60.                                 flex="1"
  61.                                 allowevents="true"
  62.                                 xbl:inherits="tooltiptext=inputtooltiptext,onfocus,onblur,value,type,maxlength,disabled,size,readonly,userAction"/>
  63.                 </xul:hbox>
  64.             </xul:hbox>
  65.  
  66.             <xul:dropmarker anonid="dropmarker"
  67.                         class="autocomplete-history-dropmarker"
  68.                         allowevents="true"/>
  69.  
  70.             <xul:popupset anonid="popupset"/>
  71.  
  72.         </content>
  73.  
  74.         <implementation implements="nsIAccessibleProvider, nsIDOMXULMenuListElement">
  75.  
  76.             <constructor><![CDATA[
  77.                 var dropmarker = document.getAnonymousElementByAttribute(this, "anonid", "dropmarker");
  78.                 dropmarker.owner = this;
  79.                 // This sets the height of the searchbox.  This method allows us to remove the
  80.                 // margin from the text field so that themes that expect no margin don't shift the
  81.                 // text field down and cut off lower portions of characters in the field.
  82.                 if (navigator.platform.toLowerCase().indexOf("mac") != -1)
  83.                 {
  84.                     dropmarker.style.height = "14px";
  85.                 }
  86.                 else
  87.                 {
  88.                     dropmarker.style.height = "20px";
  89.                 }
  90.                 this.resultsIndex = -1;
  91.                 this.prevTimeStamp = 0;
  92.  
  93.             ]]></constructor>
  94.  
  95.  
  96.             <field name="mInputElt">
  97.                 document.getAnonymousElementByAttribute(this, "anonid", "input");
  98.             </field>
  99.  
  100.             <!-- =================== nsIAccessibleProvider =================== -->
  101.  
  102.             <property name="accessible">
  103.                 <getter><![CDATA[
  104.                     // expose as a combobox
  105.                     var accService = Components.classes["@mozilla.org/accessibilityService;1"].
  106.                                 getService(Components.interfaces.nsIAccessibilityService);
  107.                     return accService.createXULComboboxAccessible(this);
  108.                 ]]></getter>
  109.             </property>
  110.  
  111.  
  112.             <!-- =================== nsIDOMXULMenuListElement =================== -->
  113.  
  114.             <property name="editable" readonly="true"
  115.                 onget="return true;" />
  116.  
  117.             <property name="crop"
  118.                 onset="this.setAttribute('crop',val); return val;"
  119.                 onget="return this.getAttribute('crop');"/>
  120.  
  121.             <property name="label" readonly="true" onget="return this.mInputElt.value;"/>
  122.  
  123.             <property name="open"
  124.                 onget="return this.getAttribute('open') == 'true';">
  125.                 <setter><![CDATA[
  126.                         if (val)
  127.                         {
  128.                             this.setAttribute("open", "true");
  129.                             this.showResultsPopup();
  130.                         }
  131.                         else
  132.                         {
  133.                             this.removeAttribute("open");
  134.                             this.closePopup();
  135.                         }
  136.                 ]]></setter>
  137.             </property>
  138.  
  139.  
  140.             <!-- =================== PUBLIC MEMBERS =================== -->
  141.  
  142.             <property name="value"
  143.                 onget="return this.mInputElt.value;">
  144.                 <setter><![CDATA[
  145.                     this.mInputElt.value = val;
  146.                     this.mKeyedValue = val;
  147.  
  148. //                    var evt = document.createEvent("UIEvents");
  149. //                    evt.initUIEvent("input", true, false, window, 0);
  150. //                    this.mIgnoreInput = true;
  151. //                    this.dispatchEvent(evt);
  152. //                    this.mIgnoreInput = false;
  153.  
  154.                     var event = document.createEvent('Events');
  155.                     event.initEvent('ValueChange', true, true);
  156.                     this.mInputElt.dispatchEvent(event);
  157.                     return val;
  158.                 ]]></setter>
  159.             </property>
  160.  
  161.  
  162.             <field name="popup"><![CDATA[
  163.                 var popup = null;
  164.                 var popupId = this.getAttribute("autocompletepopup");
  165.                 if (popupId)
  166.                     popup = document.getElementById(popupId);
  167.                 if (!popup) {
  168.                     popup = document.createElement("popup");
  169.                     popup.setAttribute("hidden", "true");
  170.  
  171.                     var popupset = document.getAnonymousElementByAttribute(this, "anonid", "popupset");
  172.                     popupset.appendChild(popup);
  173.                 }
  174.                 popup.owner = this;
  175.                 popup
  176.             ]]></field>
  177.  
  178.  
  179.             <property name="autocompleteDatasource"
  180.                         onset="this.mDatasource = val;"
  181.                         onget="return this.mDatasource;"/>
  182.  
  183.             <property name="reflectPopupLabel"
  184.                         onset="this.setAttribute('reflectpopuplabel', val); return val;"
  185.                         onget="return this.getAttribute('reflectpopuplabel') == 'true';"/>
  186.  
  187.             <property name="contextItemALabel"
  188.                         onset="this.setAttribute('contextitemalabel', val); return val;"
  189.                         onget="return this.getAttribute('contextitemalabel');"/>
  190.  
  191.             <property name="contextItemAAccesskey"
  192.                         onset="this.setAttribute('contextitemaaccesskey', val); return val;"
  193.                         onget="return this.getAttribute('contextitemaaccesskey');"/>
  194.  
  195.             <property name="contextItemAChecked"
  196.                         onset="this.setAttribute('contextitemachecked', val); return val;"
  197.                         onget="return this.getAttribute('contextitemachecked') == 'true';"/>
  198.  
  199.             <property name="contextItemACommand"
  200.                         onset="this.setAttribute('contextitemacommand', val); return val;"
  201.                         onget="return this.getAttribute('contextitemacommand');"/>
  202.  
  203.             <property name="contextItemBLabel"
  204.                         onset="this.setAttribute('contextitemblabel', val); return val;"
  205.                         onget="return this.getAttribute('contextitemblabel');"/>
  206.  
  207.             <property name="contextItemBAccesskey"
  208.                         onset="this.setAttribute('contextitembaccesskey', val); return val;"
  209.                         onget="return this.getAttribute('contextitembaccesskey');"/>
  210.  
  211.             <property name="contextItemBChecked"
  212.                         onset="this.setAttribute('contextitembchecked', val); return val;"
  213.                         onget="return this.getAttribute('contextitembchecked') == 'true';"/>
  214.  
  215.             <property name="contextItemBCommand"
  216.                         onset="this.setAttribute('contextitembcommand', val); return val;"
  217.                         onget="return this.getAttribute('contextitembcommand');"/>
  218.  
  219.             <property name="contextItemCLabel"
  220.                         onset="this.setAttribute('contextitemclabel', val); return val;"
  221.                         onget="return this.getAttribute('contextitemclabel');"/>
  222.  
  223.             <property name="contextItemCAccesskey"
  224.                         onset="this.setAttribute('contextitemcaccesskey', val); return val;"
  225.                         onget="return this.getAttribute('contextitemcaccesskey');"/>
  226.  
  227.             <property name="contextItemCChecked"
  228.                         onset="this.setAttribute('contextitemcchecked', val); return val;"
  229.                         onget="return this.getAttribute('contextitemcchecked') == 'true';"/>
  230.  
  231.             <property name="contextItemCCommand"
  232.                         onset="this.setAttribute('contextitemccommand', val); return val;"
  233.                         onget="return this.getAttribute('contextitemccommand');"/>
  234.  
  235.             <method name="onTextReverted">
  236.                 <body><![CDATA[
  237.                     return this.fireEvent("textreverted");
  238.                 ]]></body>
  239.             </method>
  240.  
  241.             <method name="onTextEntered">
  242.                 <parameter name="evt"/>
  243.                 <body><![CDATA[
  244.                     return this.fireEvent("textentered", evt);
  245.                 ]]></body>
  246.             </method>
  247. <!--            
  248.             <method name="onPageNavigationKey">
  249.                 <parameter name="evt"/>
  250.                 <body><![CDATA[
  251.                     return this.fireEvent("pagenavigationkey", evt);
  252.                 ]]></body>
  253.             </method>
  254. -->
  255.             <!-- maximum number of rows to display at a time -->
  256.             <property name="maxRows"
  257.                 onset="this.setAttribute('maxrows', val); return val;"
  258.                 onget="return parseInt(this.getAttribute('maxrows')) || 0;"/>
  259.  
  260.             <property name="selectionStart"
  261.                 onget="return this.mInputElt.selectionStart;"/>
  262.  
  263.             <property name="selectionEnd"
  264.                 onget="return this.mInputElt.selectionEnd;"/>
  265.  
  266.             <method name="selectTextRange">
  267.                 <parameter name="aStartIndex"/>
  268.                 <parameter name="aEndIndex"/>
  269.                 <body><![CDATA[
  270.                     this.mInputElt.setSelectionRange(aStartIndex, aEndIndex);
  271.                 ]]></body>
  272.             </method>
  273.  
  274.             <!-- ::::::::::::: child event handling ::::::::::::: -->
  275.  
  276.             <method name="handlePopupShowing">
  277.                 <body><![CDATA[
  278.                     this.setAttribute("open", "true");
  279.                     document.getAnonymousElementByAttribute(this, "anonid", "dropmarker").setAttribute("open", "true");
  280.                 ]]></body>
  281.             </method>
  282.  
  283.             <method name="handlePopupHiding">
  284.                 <body><![CDATA[
  285.                     setTimeout(this.clearOpenProperty, 0, this);
  286.                     document.getAnonymousElementByAttribute(this, "anonid", "dropmarker").setAttribute("open", "false");
  287.                     this.resultsIndex = -1;
  288.                 ]]></body>
  289.             </method>
  290.  
  291.             <method name="handlePopupCommand">
  292.                 <parameter name="evt"/>
  293.                 <body><![CDATA[
  294.                     this.value = evt.target.label;
  295.                 ]]></body>
  296.             </method>
  297.  
  298.             <method name="handleDropmarkerMousedown">
  299.                 <body><![CDATA[
  300.                     this.toggleResultsPopup();
  301.                 ]]></body>
  302.             </method>
  303.  
  304.             <method name="clearOpenProperty">
  305.                 <parameter name="searchbox"/>
  306.                 <body><![CDATA[
  307.                     searchbox.setAttribute("open", "false");
  308.                 ]]></body>
  309.             </method>
  310.  
  311.             <!-- =================== PRIVATE MEMBERS =================== -->
  312.  
  313.             <!-- ::::::::::::: event dispatching ::::::::::::: -->
  314.  
  315.             <method name="fireEvent">
  316.                 <parameter name="aEventType"/>
  317.                 <body><![CDATA[
  318.                     var cancel = false;
  319.                     // handle any xml attribute event handlers
  320.                     var handler = this.getAttribute("on" + aEventType);
  321.                     if (handler) {
  322.                         var fn = new Function("eventType", "param", handler);
  323.                         cancel = fn.apply(this, arguments);
  324.                     }
  325.                     return cancel;
  326.                 ]]></body>
  327.             </method>
  328.  
  329.             <!-- ::::::::::::: popup open/close ::::::::::::: -->
  330.  
  331.             <method name="openPopup">
  332.                 <body><![CDATA[
  333.                     this.popup.showPopup(
  334.                                 this,
  335.                                 -1,
  336.                                 -1,
  337.                                 "popup",
  338.                                 "bottomleft",
  339.                                 "topleft");
  340.                 ]]></body>
  341.             </method>
  342.  
  343.             <method name="closePopup">
  344.                 <body><![CDATA[
  345.                     this.popup.hidePopup();
  346.                 ]]></body>
  347.             </method>
  348.  
  349.             <method name="showResultsPopup">
  350.                 <body><![CDATA[
  351.  
  352.                     while (this.popup.hasChildNodes())
  353.                         this.popup.removeChild(this.popup.lastChild);
  354.  
  355.  
  356.                     // If building the results list ever becomes an
  357.                     // extremely lengthy operation, we can change 'results'
  358.                     // to an enumerator and build the list incrementally.
  359.  
  360.                     var results = this.mDatasource.getResults();
  361.  
  362.                     if (results.length > 0)
  363.                     {
  364.                         for (var i = 0; (i < results.length) && (i < this.maxRows); i++)
  365.                         {
  366.                             var item = document.createElement("menuitem");
  367.  
  368.                             if (navigator.platform.toLowerCase().indexOf("mac") != -1)
  369.                                 item.setAttribute("class", "su_macpopup");
  370.  
  371.                             for (var j in results[i])
  372.                             {
  373.                                 if (this.isPropertyGarbage(results[i], j)) continue;
  374.                                 item.setAttribute(j, results[i][j]);
  375.                             }
  376.                             this.popup.appendChild(item);
  377.                         }
  378.                         this.openPopup();
  379.                     }
  380.                     else
  381.                     {
  382.                         this.closePopup();
  383.                     }
  384.                 ]]></body>
  385.             </method>
  386.  
  387.             <method name="toggleResultsPopup">
  388.                 <body><![CDATA[
  389.                     if (this.open)
  390.                         this.closePopup();
  391.                     else
  392.                         this.showResultsPopup();
  393.                 ]]></body>
  394.             </method>
  395.             
  396.             <method name="dd">
  397.                 <parameter name="val"/>
  398.                 <body><![CDATA[
  399.                     Components.classes["@mozilla.org/consoleservice;1"]
  400.                                 .getService(Components.interfaces.nsIConsoleService)
  401.                                 .logStringMessage("" + val);
  402.                 ]]></body>
  403.             </method>
  404.             
  405.             <method name="dumpObject">
  406.                 <parameter name="o"/>
  407.                 <body><![CDATA[
  408.                     var str = "";
  409.                     var p;
  410.                     for (p in o)
  411.                     {
  412.                         try {
  413.                             str += "[" + p + "]\n" + o[p] + "\n\n";
  414.                         } catch (e) {
  415.                             str += "[" + p + "] ERROR\n" + e + "\n\n";
  416.                         }
  417.                     }
  418.                 
  419.                     Components.classes["@mozilla.org/consoleservice;1"]
  420.                                 .getService(Components.interfaces.nsIConsoleService)
  421.                                 .logStringMessage("###\n" + str);
  422.                 ]]></body>
  423.             </method>
  424.             
  425.  
  426.             <!-- ::::::::::::: key navigation ::::::::::::: -->
  427.  
  428.             <method name="handleKeydown">
  429.                 <parameter name="evt"/>
  430.                 <body><![CDATA[
  431.                     var cancel;
  432.  
  433.                     if (evt.timeStamp == this.prevTimeStamp)
  434.                         return true;
  435.                     
  436.                     this.prevTimeStamp = evt.timeStamp;
  437.  
  438.                     if (((evt.keyCode == KeyEvent.DOM_VK_TAB) && (this.open)) ||
  439.                                 ((evt.keyCode == KeyEvent.DOM_VK_RETURN) && (this.open)))
  440.                     {
  441.                         evt.stopPropagation();
  442.                         evt.preventDefault();
  443.                         return false;
  444.                     }
  445.                     return true;
  446.                 ]]></body>
  447.             </method>
  448.  
  449.             <method name="handleKeyup">
  450.                 <parameter name="evt"/>
  451.                 <body><![CDATA[
  452.                     if (evt.timeStamp == this.prevTimeStamp)
  453.                         return true;
  454.                     
  455.                     this.prevTimeStamp = evt.timeStamp;
  456. /*
  457.                     if ((evt.ctrlKey || evt.metaKey) &&
  458.                                 ((evt.keyCode == KeyEvent.DOM_VK_UP) ||
  459.                                 (evt.keyCode == KeyEvent.DOM_VK_DOWN) ||
  460.                                 (evt.keyCode == KeyEvent.DOM_VK_PAGE_UP) ||
  461.                                 (evt.keyCode == KeyEvent.DOM_VK_PAGE_DOWN)))
  462.                     {
  463.                         this.onPageNavigationKey(evt);
  464.                         return true;
  465.                     }
  466. */
  467.                     if ((evt.keyCode == KeyEvent.DOM_VK_UP)
  468.                                 || ((evt.keyCode == KeyEvent.DOM_VK_TAB) && evt.shiftKey))
  469.  
  470.                     {
  471.                         if (this.open)
  472.                         {
  473.                             this.resultsIndex--;
  474.                             if (this.resultsIndex == -2)
  475.                             {
  476.                                 this.resultsIndex = this.popup.childNodes.length - 1;
  477.                                 this.popup.childNodes[this.resultsIndex].setAttribute('_moz-menuactive', 'true');
  478.                                 if (this.reflectPopupLabel)
  479.                                 {
  480.                                     this.mInputElt.value = this.popup.childNodes[this.resultsIndex].label;
  481.                                 }
  482.                             }
  483.                             else if (this.resultsIndex == -1)
  484.                             {
  485.                                 this.popup.childNodes[this.resultsIndex + 1].removeAttribute('_moz-menuactive');
  486.                                 if (this.reflectPopupLabel)
  487.                                 {
  488.                                     this.mInputElt.value = this.mKeyedValue;
  489.                                 }
  490.                             }
  491.                             else
  492.                             {
  493.                                 if ((this.resultsIndex + 1) < this.popup.childNodes.length)
  494.                                 {
  495.                                     this.popup.childNodes[this.resultsIndex + 1].removeAttribute('_moz-menuactive');
  496.                                 }
  497.                                 this.popup.childNodes[this.resultsIndex].setAttribute('_moz-menuactive', 'true');
  498.                                 if (this.reflectPopupLabel)
  499.                                 {
  500.                                     this.mInputElt.value = this.popup.childNodes[this.resultsIndex].label;
  501.                                 }
  502.                             }
  503.                         }
  504.                         else if (evt.keyCode != KeyEvent.DOM_VK_TAB)
  505.                         {
  506.                             this.showResultsPopup();
  507.                             if (this.reflectPopupLabel)
  508.                             {
  509.                                 this.mKeyedValue = this.mInputElt.value;
  510.                             }
  511.                         }
  512.                     }
  513.                     else if ((evt.keyCode == KeyEvent.DOM_VK_DOWN)
  514.                                 || ((evt.keyCode == KeyEvent.DOM_VK_TAB) && (! evt.shiftKey)))
  515.                     {
  516.                         if (this.open)
  517.                         {
  518.                             this.resultsIndex++;
  519.                             if (this.resultsIndex == this.popup.childNodes.length + 1)
  520.                             {
  521.                                 this.resultsIndex = 0;
  522.                                 this.popup.childNodes[this.resultsIndex].setAttribute('_moz-menuactive', 'true');
  523.                                 if (this.reflectPopupLabel)
  524.                                 {
  525.                                     this.mInputElt.value = this.popup.childNodes[this.resultsIndex].label;
  526.                                 }
  527.                             }
  528.                             else if (this.resultsIndex == this.popup.childNodes.length)
  529.                             {
  530.                                 this.popup.childNodes[this.resultsIndex - 1].removeAttribute('_moz-menuactive');
  531.                                 this.resultsIndex = -1;
  532.                                 if (this.reflectPopupLabel)
  533.                                 {
  534.                                     this.mInputElt.value = this.mKeyedValue;
  535.                                 }
  536.                             }
  537.                             else
  538.                             {
  539.                                 if ((this.resultsIndex - 1) >= 0)
  540.                                 {
  541.                                     this.popup.childNodes[this.resultsIndex - 1].removeAttribute('_moz-menuactive');
  542.                                 }
  543.                                 this.popup.childNodes[this.resultsIndex].setAttribute('_moz-menuactive', 'true');
  544.                                 if (this.reflectPopupLabel)
  545.                                 {
  546.                                     this.mInputElt.value = this.popup.childNodes[this.resultsIndex].label;
  547.                                 }
  548.                             }
  549.                         }
  550.                         else if (evt.keyCode != KeyEvent.DOM_VK_TAB)
  551.                         {
  552.                             this.showResultsPopup();
  553.                             if (this.reflectPopupLabel)
  554.                             {
  555.                                 this.mKeyedValue = this.mInputElt.value;
  556.                             }
  557.                         }
  558.                     }
  559.                     else if ((evt.keyCode == KeyEvent.DOM_VK_LEFT)
  560.                                 || (evt.keyCode == KeyEvent.DOM_VK_RIGHT)
  561.                                 || (evt.keyCode == KeyEvent.DOM_VK_HOME)
  562.                                 || (evt.keyCode == KeyEvent.DOM_VK_END))
  563.                     {
  564.                         if (this.open)
  565.                         {
  566.                             this.closePopup();
  567.                         }
  568.                     }
  569.                     else if (evt.keyCode == KeyEvent.DOM_VK_PAGE_UP)
  570.                     {
  571.                         if (this.open)
  572.                         {
  573.                             if (this.resultsIndex == -1)
  574.                             {
  575.                                 this.resultsIndex = this.popup.childNodes.length - 1;
  576.                                 this.popup.childNodes[this.resultsIndex].setAttribute('_moz-menuactive', 'true');
  577.                                 if (this.reflectPopupLabel)
  578.                                 {
  579.                                     this.mInputElt.value = this.popup.childNodes[this.resultsIndex].label;
  580.                                 }
  581.                             }
  582.                             else if (this.resultsIndex == this.popup.childNodes.length -1)
  583.                             {
  584.                                 this.popup.childNodes[this.resultsIndex].removeAttribute('_moz-menuactive');
  585.                                 this.resultsIndex = 0;
  586.                                 this.popup.childNodes[this.resultsIndex].setAttribute('_moz-menuactive', 'true');
  587.                                 if (this.reflectPopupLabel)
  588.                                 {
  589.                                     this.mInputElt.value = this.popup.childNodes[this.resultsIndex].label;
  590.                                 }
  591.                             }
  592.                             else if (this.resultsIndex == 0)
  593.                             {
  594.                                 this.popup.childNodes[this.resultsIndex].removeAttribute('_moz-menuactive');
  595.                                 this.resultsIndex = -1;
  596.                                 if (this.reflectPopupLabel)
  597.                                 {
  598.                                     this.mInputElt.value = this.mKeyedValue;
  599.                                 }
  600.                             }
  601.                         }
  602.                         else
  603.                         {
  604.                             this.showResultsPopup();
  605.                             if (this.reflectPopupLabel)
  606.                             {
  607.                                 this.mKeyedValue = this.mInputElt.value;
  608.                             }
  609.                         }
  610.                     }
  611.                     else if (evt.keyCode == KeyEvent.DOM_VK_PAGE_DOWN)
  612.                     {
  613.                         if (this.open)
  614.                         {
  615.                             if (this.resultsIndex == -1)
  616.                             {
  617.                                 this.resultsIndex = 0;
  618.                                 this.popup.childNodes[this.resultsIndex].setAttribute('_moz-menuactive', 'true');
  619.                                 if (this.reflectPopupLabel)
  620.                                 {
  621.                                     this.mInputElt.value = this.popup.childNodes[this.resultsIndex].label;
  622.                                 }
  623.                             }
  624.                             else if (this.resultsIndex == this.popup.childNodes.length -1)
  625.                             {
  626.                                 this.popup.childNodes[this.resultsIndex].removeAttribute('_moz-menuactive');
  627.                                 this.resultsIndex = -1;
  628.                                 if (this.reflectPopupLabel)
  629.                                 {
  630.                                     this.mInputElt.value = this.mKeyedValue;
  631.                                 }
  632.                             }
  633.                             else if (this.resultsIndex == 0)
  634.                             {
  635.                                 this.popup.childNodes[this.resultsIndex].removeAttribute('_moz-menuactive');
  636.                                 this.resultsIndex = this.popup.childNodes.length - 1;
  637.                                 this.popup.childNodes[this.resultsIndex].setAttribute('_moz-menuactive', 'true');
  638.                                 if (this.reflectPopupLabel)
  639.                                 {
  640.                                     this.mInputElt.value = this.popup.childNodes[this.resultsIndex].label;
  641.                                 }
  642.                             }
  643.                         }
  644.                         else
  645.                         {
  646.                             this.showResultsPopup();
  647.                             if (this.reflectPopupLabel)
  648.                             {
  649.                                 this.mKeyedValue = this.mInputElt.value;
  650.                             }
  651.                         }
  652.                     }
  653.                     else if (evt.keyCode == KeyEvent.DOM_VK_ESCAPE)
  654.                     {
  655.                         if (this.open)
  656.                         {
  657.                             this.closePopup();
  658.                             if (this.reflectPopupLabel)
  659.                             {
  660.                                 this.mInputElt.value = this.mKeyedValue;
  661.                             }
  662.                         }
  663.                         else
  664.                         {
  665.                             this.onTextReverted();
  666.                         }
  667.                     }
  668.                     // For now, I'm assuming that OS9 and OSX both have this weird keyCode
  669.                     // 77 behavior for ctrl-return. -- JW
  670.                     else if (((navigator.platform.toLowerCase().indexOf("mac") == -1) && 
  671.                         (evt.keyCode == KeyEvent.DOM_VK_RETURN)) ||
  672.                         ((navigator.platform.toLowerCase().indexOf("mac") != -1) &&
  673.                         ((evt.ctrlKey && (evt.keyCode == 77)) || ((! evt.ctrlKey) && 
  674.                         (evt.keyCode == KeyEvent.DOM_VK_RETURN)))))
  675.                     {
  676.                         if((this.open) && (this.resultsIndex == -1))
  677.                         {
  678.                             this.closePopup();
  679.                             this.onTextEntered(evt);
  680.                         }
  681.                         else if ((this.open) && (this.resultsIndex != -1))
  682.                         {
  683.                             this.mInputElt.value = this.popup.childNodes[this.resultsIndex].label;
  684.                             this.popup.hidePopup();
  685.                             if (evt.ctrlKey || evt.metaKey)
  686.                             {
  687.                                 this.onTextEntered(evt);
  688.                             }
  689.                         }
  690.                         else
  691.                         {
  692.                             this.onTextEntered(evt);
  693.                         }
  694.                     }
  695.                     else if (evt.keyCode == KeyEvent.DOM_VK_F4)
  696.                     {
  697.                         this.toggleResultsPopup();
  698.                     }
  699.                     else
  700.                     {
  701.                         if (this.mInputElt.value != this.mKeyedValue)
  702.                         {
  703.                             this.mKeyedValue = this.mInputElt.value;
  704.                             if (this.mKeyedValue == "")
  705.                             {
  706.                                 this.closePopup();
  707.                             }
  708.                             else
  709.                             {
  710.                                 this.showResultsPopup();
  711.                             }
  712.                         }
  713.                     }
  714.  
  715.                     return true;
  716.                 ]]></body>
  717.             </method>
  718.  
  719.             <!-- ::::::::::::: utilities ::::::::::::: -->
  720.  
  721.             <method name="isPropertyGarbage">
  722.                 <parameter name="obj"/>
  723.                 <parameter name="prop"/>
  724.                 <body><![CDATA[
  725.                     var garbage_flag = false;
  726.                     switch (prop.toLowerCase())
  727.                     {
  728.                         case "tojsonstring":
  729.                         case "toxmlrpcparam":
  730.                             garbage_flag = true;
  731.                         break;
  732.                         default:
  733.                             if ((typeof (obj[prop])) == "function")
  734.                             {
  735.                                 garbage_flag = true;
  736.                             }
  737.                         break;
  738.                     }
  739.                     return garbage_flag;
  740.                 ]]></body>
  741.             </method>
  742.         </implementation>
  743.  
  744.         <handlers>
  745.             <handler event="keydown" phase="capturing"
  746.                              action="return this.handleKeydown(event);"/>
  747.             <handler event="keyup" phase="capturing"
  748.                              action="return this.handleKeyup(event);"/>
  749.         </handlers>
  750.     </binding>
  751.  
  752.  
  753.     <binding id="su_autocompletepopup" extends="chrome://global/content/bindings/popup.xml#popup">
  754.         <implementation>
  755.             <constructor><![CDATA[
  756.                 this.setAttribute("ignorekeys", "true");
  757.             ]]></constructor>
  758.         </implementation>
  759.  
  760.         <handlers>
  761.             <handler event="popupshowing"><![CDATA[
  762.                 this.owner.handlePopupShowing();
  763.             ]]></handler>
  764.  
  765.             <handler event="popuphiding"><![CDATA[
  766.                 this.owner.handlePopupHiding();
  767.             ]]></handler>
  768.  
  769.             <handler event="command"><![CDATA[
  770.                 this.owner.handlePopupCommand(event);
  771.             ]]></handler>
  772.         </handlers>
  773.     </binding>
  774.  
  775.  
  776.     <binding id="su_autocompletedropmarker" extends="xul:button">
  777.         <content>
  778.             <xul:image/>
  779.         </content>
  780.  
  781.         <implementation implements="nsIAccessibleProvider">
  782.             <property name="accessible">
  783.                 <getter><![CDATA[
  784.                     var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
  785.                     return accService.createXULDropmarkerAccessible(this);
  786.                 ]]></getter>
  787.             </property>
  788.         </implementation>
  789.  
  790.         <handlers>
  791.             <handler event="mousedown"
  792.                 button="0"
  793.                 action="return this.parentNode.handleDropmarkerMousedown(event)"/>
  794.         </handlers>
  795.     </binding>
  796.  
  797.   <binding id="su_autocompletecontext">
  798.     <content context="_child">
  799.       <children/>
  800.       <xul:menupopup anonid="input-box-contextmenu"
  801.           onpopupshowing="if (document.commandDispatcher.focusedElement != this.parentNode.firstChild) { this.parentNode.firstChild.focus(); }; this.parentNode.initPopupItems(this);"
  802.         oncommand="var command = event.originalTarget.getAttribute('cmd'); if (command) { this.parentNode.doCommand(); event.preventBubble(); }">
  803.                 <xul:menuitem label="&undoCmd.label;" accesskey="&undoCmd.accesskey;" cmd="cmd_undo"/>
  804.                 <xul:menuseparator/>
  805.                 <xul:menuitem label="&cutCmd.label;" accesskey="&cutCmd.accesskey;" cmd="cmd_cut"/>
  806.                 <xul:menuitem label="©Cmd.label;" accesskey="©Cmd.accesskey;" cmd="cmd_copy"/>
  807.                 <xul:menuitem label="&pasteCmd.label;" accesskey="&pasteCmd.accesskey;" cmd="cmd_paste"/>
  808.                 <xul:menuitem label="&deleteCmd.label;" accesskey="&deleteCmd.accesskey;" cmd="cmd_delete"/>
  809.                 <xul:menuseparator/>
  810.                 <xul:menuitem label="&selectAllCmd.label;" accesskey="&selectAllCmd.accesskey;" cmd="cmd_selectAll"/>
  811.                 <xul:menuseparator anonid="contextitemseparator"/>
  812.                 <xul:menuitem anonid="contextitema"
  813.                     type="checkbox"
  814.                     checked="true"
  815.                     xbl:inherits="label=contextitemalabel,accesskey=contextitemaaccesskey,checked=contextitemachecked,oncommand=contextitemaoncommand"/>
  816.                 <xul:menuitem anonid="contextitemb"
  817.                     type="checkbox"
  818.                     checked="true"
  819.                     xbl:inherits="label=contextitemblabel,accesskey=contextitembaccesskey,checked=contextitembchecked,oncommand=contextitemboncommand"/>
  820.                 <xul:menuitem anonid="contextitemc"
  821.                     type="checkbox"
  822.                     checked="true"
  823.                     xbl:inherits="label=contextitemclabel,accesskey=contextitemcaccesskey,checked=contextitemcchecked,oncommand=contextitemconcommand"/>
  824.       </xul:menupopup>
  825.     </content>
  826.     <implementation>
  827.       <method name="initPopupItems">
  828.         <parameter name="popupNode"/>
  829.         <body>
  830.           <![CDATA[
  831.             var children = popupNode.childNodes;
  832.             for (var i = 0; i < children.length; i++)
  833.             {
  834.               var command = children[i].getAttribute("cmd");
  835.               if (command)
  836.               {
  837.                 var controller = document.commandDispatcher.getControllerForCommand(command);
  838.                 var enabled = controller.isCommandEnabled(command);
  839.                 if (enabled)
  840.                   children[i].removeAttribute("disabled");
  841.                 else
  842.                   children[i].setAttribute("disabled", "true");
  843.               }
  844.                         }
  845.           ]]>
  846.         </body>
  847.       </method>
  848.  
  849.       <method name="doCommand">
  850.         <parameter name="command"/>
  851.         <body>
  852.           <![CDATA[
  853.             var controller = document.commandDispatcher.getControllerForCommand(command);
  854.             controller.doCommand(command);
  855.           ]]>
  856.         </body>
  857.       </method>
  858.     </implementation>
  859.   </binding>
  860.  
  861. </bindings>
  862.  
  863.